'use client';
import {ReactNode} from 'react';
import {Provider} from 'react-redux';
import {createStore} from '@/store';
import {rootStateType, setValue} from '@/store/root';

const StoreProvider = ({children, state}: {
    children: ReactNode,
    state?: {root: rootStateType}
}) => {
    const store = createStore();
    store.dispatch(setValue({...state?.root}));

    return <Provider store={store}>
        {children}
    </Provider>;
};

export default StoreProvider;
